<template>
  <div class="page-cart">
    <el-row>
      <el-col class="m-cart" v-if="1||cart.length" :span="24">
        <list/>
        <p>应付金额<em class="money">￥{{total}}</em></p>
        <div class="post">
          <el-button type="primary" @click="submit">提交订单</el-button>
        </div>
      </el-col>
      <el-col class="empty" v-else :span="24">购物车为空</el-col>
    </el-row>
  </div>
</template>

<script type="text/ecmascript-6">
  import List from '../components/cart/list'

  export default {
    components: {
      List
    },
    data() {
      return {
        cart: []
      }
    },
    computed: {
      total() {
        let total = 0
        this.cart.forEach(item => {
          total += item.price * item.count
        })
        return total
      }
    },
    methods: {
      submit() {
      }
    }
  }
</script>

<style lang="scss">
  @import "@/assets/css/cart/index.scss";
</style>
